package cn.bugstack.initializr.rigger.domain.service.module.impl;

import cn.bugstack.initializr.rigger.domain.model.ProjectInfo;
import cn.bugstack.initializr.rigger.domain.model.ShellInfo;
import cn.bugstack.initializr.rigger.domain.service.module.BaseModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class GenerationShellInfo  extends BaseModule {
    private Logger logger = LoggerFactory.getLogger(GenerationLogBackInfo.class);

    public void doGeneration(ProjectInfo projectInfo, String projectsRoot, String lastPackageName) throws Exception {
        ShellInfo shellInfo = new ShellInfo(projectInfo.getName());
        File file = new File(
                projectsRoot + projectInfo.getArtifactId() + "/src/main/shell/",
                projectInfo.getName()+".sh"
        );

        // 写入文件
        super.writeFile(file, "shell.ftl", shellInfo);

        logger.info("创建配置文件 "+projectInfo.getName()+".sh {}", file.getPath());
    }
}
